﻿<?php
header("Content-Type:text/html; charset=utf-8");

require_once("../connectMysql/connetMysql.class.php");
$db=new connetMysql;
$con=$db->getConnect();

session_start();               //为了将验证码打乱
$_SESSION['checkCode']=md5(time());     //将验证码的值存入session中
$username = $_POST["input_username"];
$userpassword = $_POST["input_userpassword"];
if(isset($_POST["menberPass"]))
{
	$menberPass=$_POST["menberPass"];
}
else
{
	$menberPass="false";
}


$result = mysqli_query($con,"SELECT * FROM user where username='$username' AND userpassword='$userpassword' AND userstate='1'");
$result2 = mysqli_query($con,"SELECT * FROM user where usermail='$username' AND userpassword='$userpassword' AND userstate='1'");

if($row = mysqli_fetch_array($result))
  {
  	  $_SESSION['user']=$row['username'];
	  $_SESSION['language']=$row['language'];
	  if("true"==$menberPass)
	  {
	  		setcookie("user",$row['username'], time()+3600*24*30);
			 Header("Location:../index/reflectIndex.php");
	  }
  		//$_COOKIE["user"]
 	
	 // echo "登陆成功！";   
  }
else if($row2 = mysqli_fetch_array($result2))
{
	 $_SESSION['user']=$row2['username'];
	 //echo $menberPass;
	  if("true"==$menberPass)
	  {
	  		setcookie("user",$row2['username'], time()+3600*24*30);
			 Header("Location:../index/reflectIndex.php");
	  }
  		//$_COOKIE["user"]
 	

	  //echo $row2['username'];   
}
else
  {
	  echo "<script>alert('登录失败');</script>";
	  echo "<script>window.location.href='../login/login.html'</script>";
	  	
  }

mysqli_close($con);
?>
